home *** CD-ROM | disk | FTP | other *** search
Gui4CLI script | 2001-08-17 | 10.8 KB | 521 lines |
- G4C
-
- WINBIG 0 10 600 220 Table.gc
- ; Table.gc V1.05 17 Aug 2001
- ; Author: Joseph Duchâtelet jduchatelet @arcadis.be
- WINTYPE 11110001
- RESINFO 8 640 256
-
- xONLOAD Fl2Tr 2File
- Gosub #this Default
-
- xONRELOAD
- Gosub #this Default
-
- xROUTINE Default
- SetGad #this 1 HIDE
- SetGad #this 3 HIDE
- Extract #this GUIPATH mypath
- IFEXISTS ASSIGN ~guitb:
- Assign guitb: '$mypath' ; mypath :=> path of the drawer Assign.gc is in
- ;EzReq 'Do you want to add the assign to user_startup ?' 'ok|no' var
- ENDIF
- cd guitb:
- GuiLoad guitb:Table.Cfg
- IF $.TbCfg_Help = ON
- GuiLoad guitb:Table.hlp
- ENDIF
- NwWdth = 450 ; new max table width
- InitReq = YES
- IF $Fl2Tr = ''
- GuiOpen #this
- IF $InitReq = YES
- ReqFile 0 0 240 200 "Get HTML file to transform " LOAD Fl2Tr #guitb:2Transform/#?
- CLI 'Faststrip $Fl2Tr 13 10'
- LVUse #this 2
- Extract Fl2Tr FILE FlNm
- LVChange $Fl2Tr
- ENDIF
-
- ELSE
- LVUse #this 2
- IF $2File = ''
- 2File = $Fl2Tr
- ENDIF
- IFEXISTS FILE $Fl2Tr
- Extract Fl2Tr FILE FlNm
- LVChange $Fl2Tr
- Gosub #this TransformIt
- LVSave $2File
- ELSE
- EzReq "No such file as $Fl2Tr" "ok" var
- ENDIF
- ENDIF
- ChCtr = 0
-
-
- xONCLOSE
- Delete env:.Tb#?
- GuiQuit Table.Cfg
- GuiClose Table.hlp
- GuiQuit #this
-
- xBUTTON 0 0 60 14 LdHTML ; <<LdHTML>>
- GadHelp "Load HTML source to check and modify"
- ReqFile 0 0 240 200 "Get HTML file to transform " LOAD Fl2Tr #guitb:2Transform/
- IFEXISTS FILE $Fl2Tr
- Extract Fl2Tr FILE FlNm
- LVUse #this 2
- CLI 'Faststrip $Fl2Tr 13 10'
- LVChange $Fl2Tr
- LVUSE #this 1
- LVClear
- LVUse #this 2
- ELSE
- EzReq "No such file as $Fl2Tr" "ok" var
- ENDIF
-
- xBUTTON 60 0 60 14 VwImL ; <<VwImL>>
- GadHelp "View Image list"
- Gosub #this ShowImgList
- LVGo first
- IF $LVVar1 = ''
- EzReq "no list, create it ?" "yes|no" var
- IF $var = 1
- Gosub #this ImagesAll
- ENDIF
- ENDIF
-
- xBUTTON 120 0 60 14 VwHTML ; <<VwHTML>>
- GadHelp "View HTML source"
- Gosub #this ShowIt
-
-
- xBUTTON 180 0 60 14 "Trsform" ; <<Trsform>>
- GadHelp "Transform the litigious table widths to preset NwWdth = $NwWdth"
- Gosub #this TransformIt
-
- xBUTTON 240 0 60 14 "Strip" ; <<Strip>>
- GadHelp "Strip all images"
- IF $$LV.ID = 2
- EZReq "Strip all images, select to strip? " "All|SStr|Stop" var
- If $var = 1
- Gosub #this StripIt
- ELSEIF $var = 2
- Gosub #this ImagesAll
- EzReq "Select the images you want to delete, then hit <<Strip>> again" "ok" var
- ELSEIF $var = 0
- stop
- ENDIF
- ELSE
- Gosub #this DelImgSelect
- ENDIF
-
- xROUTINE DelImgSelect ; LV1
- SetGad #this 2 HIDE
- SetGad #this 1 HIDE
- Ctr = 0
- LVMULTI FIRST
- WHILE $$LV.LINE > ''
- ++Ctr
- Img = $LVVar1
- LVUse #this 2
- LVSearch $Img CI FIRST
- RepVar LVVar2 $Img "" CI
- LVUse #this 1
- LVMulti NEXT
- ENDWHILE
- LVDEL SELECTED
- EzReq "Deleted $Ctr images" ok var
- Gosub #this ShowIt
-
- xROUTINE ToggleSelect
- Top = $$LV.Top
- SetGad #this $$LV.ID HIDE
- LVGo FIRST
- WHILE $$LV.LINE > ''
- IF $$LV.SEL = 0
- LVMulti ON
- ELSE
- LVMulti OFF
- ENDIF
- LVGo NEXT
- ENDWHILE
- SetGad #this $$LV.ID SHOW
- GadRedraw #this 2 2 2 2 0
- LVMove #$Top
-
- xROUTINE ToggleSelect3
- SetGad #this $$LV.ID HIDE
- SelSt.0 = OFF
- SelSt.1 = ON
- LVGo FIRST
- WHILE $$LV.LINE > ''
- ;LVMULTI "$SelSt.$$LV.SEL" ; dos not work
- LVGo NEXT
- ENDWHILE
- SetGad #this $$LV.ID SHOW
- Redraw #this
-
-
- xROUTINE ToggleSelect2 ;
- LVGo LAST
- LineLst = $$LV.LINE
- LVMulti FIRST
- IF $$LV.LINE > 0 ; file starts with an unselected block
- Line1 = $$LV.LINE ; begin of next selected block
- LVGo FIRST
- WHILE $$LV.LINE < $Line1
- LVMULTI ON
- LVGo Next
- ENDWHILE
- ; now we are on 1st line of selected block (Line1)
- Gosub #this Sel2Unsel ; till we are on a first unselected line
- ELSE ; first line selected
- LVGo FIRST
- Gosub #this Sel2Unsel ; till we are on a first unselected line
- ENDIF
-
-
- xROUTINE Sel2Unsel
- WHILE $$LV.LINE > ''
- AND $$LV.SEL = 1
- LVMulti OFF
- LVGo Next
- ENDWHILE ; unselcted now
- IF $$LV.LINE > ''
- Line0 = $$LV.LINE ; begin of an unselected block
- Gosub #this Unsel2Sel
- ENDIF
-
-
- xROUTINE Unsel2Sel
- LVMulti NEXT
- IF $$LV.LINE > $Line0 ; always the case unless there is no selected any more
- Line1 = $$LV.LINE
- ELSE
- Line1 = $LineLst
- ENDIF
- LVGo #$Line0
- WHILE $$LV.LINE < $Line1
- LVMULTI ON
- LVGo Next
- ENDWHILE
- IF $Line1 < $LineLst
- Gosub #this Sel2Unsel
- ENDIF
-
-
-
- xROUTINE DelImgNotSelect ; LV1
- SetGad #this 2 HIDE
- SetGad #this 1 HIDE
- Ctr = 0
- LVMULTI FIRST
- WHILE $$LV.LINE > ''
- ++Ctr
- Img = $LVVar1
- LVUse #this 2
- LVSearch $Img CI FIRST
- RepVar LVVar2 $Img "" CI
- LVUse #this 1
- LVMulti NEXT
- ENDWHILE
- LVDEL SELECTED
- EzReq "Deleted $Ctr images" ok var
- Gosub #this ShowIt
-
- xROUTINE ImagesAll
- SetGad #this 1 HIDE
- SetGad #this 2 HIDE
- LVUse #this 1
- LVClear
- LVUse #this 2
- SetGad #this 2 HIDE
- Ctr = 0
- LVSearch "<img" CI FIRST
- While $$LV.LINE > ''
- ++Ctr
- PosH = $$Search.Pos
- LVSearch ">" CI NEXT
- PosT = $$Search.Pos
- Lgt = $($PosT - $PosH)
- ImSgmt.$Ctr = $LVVar2[$PosH][$Lgt]
- LVUse #this 1
- LVAdd "$ImSgmt.$Ctr"
- LVUse #this 2
- Line.$Ctr = $$LV.LINE
- PosH.$Ctr = $PosH
- Lgt.$Ctr = $Lgt
- LVSearch "<img" CI NEXT
- EndWhile
- Gosub #this ShowImgList
-
- xROUTINE ShowImgList
- SetGad #this 2 HIDE
- SetGad #this 2 HIDE
- SetGad #this 1 SHOW
- Redraw #this
- LVUse #this 1
-
- xROUTINE StripIt
- Set BUFFERS 2048
- LVUse #this 2
- SetGad #this 2 HIDE
- Ctr = 0
- LVSearch "<img" CI FIRST
- While $$LV.LINE > ''
- t = $$LV.REC
- While $$SEARCH.POS > ''
- ++Ctr
- CutVar t Cut Char $$SEARCH.POS s
- SearchVar t ">" CI FIRST
- CutVar t Cut Char $($$SEARCH.POS + 1) r
- AppVar s $t
- t = $s
- SearchVar t "<img" CI FIRST
- EndWhile
- LVPut $t
- LVSearch "<img" CI NEXT
- EndWhile
- TotCtr = $($TotCtr + $Ctr)
- EzReq "Stripped $TotCtr images" ok var
- LVUse #this 1
- LVClear
- Gosub #this ShowIt
- Set BUFFERS 1024
-
- xBUTTON 300 0 60 14 Save ; <<Save>>
- GadHelp "Save the (transformed?) file"
- IF $$LV.ID = 2
- ;PropFl = 'guitb:Transformed/\#$FlNm '
- ReqFile 0 0 240 200 "Save your file as ? " SAVE FlSv #guitb:Transformed/$FlNm
- IF $FlSv > ''
- LVSave $FlSv
- EzReq "Delete original html file ? " "ok|stop" var
- IF $var = 1
- Delete $Fl2Tr
- ENDIF
- ENDIF
- ELSE
- ReqFile 0 0 240 200 "Save your imagelist as ? " SAVE ImSv #guitb:ImageList/$FlNm
- IF $ImSv > ''
- LVSave $ImSv
- ENDIF
- ENDIF
-
- xBUTTON 360 0 20 14 "Al" ; <<Al>>
- GadHelp "Select all selected lines"
- LVMulti ALL
-
- xBUTTON 380 0 20 14 "Nn" ; <<Nn>>
- GadHelp "Deselect all selected lines"
- LVMulti NONE
-
- xBUTTON 400 0 20 14 "Tg" ; <<Tg>>
- GadHelp "Toggle selected lines"
- Gosub #this ToggleSelect
-
-
-
- xROUTINE TransformIt
- GuiWindow #this WAIT
- LVUse #this 2
- SetGad #this 2 HIDE
- LVGo first ;EXP000 LVXpos = 0
- ChCtr = 0
- Ctr = 0
- LVSearch '<table' CI FIRST
- WHILE $$LV.LINE > ''
- Gosub #this TransformLine
- LVUse #this 2
- LVSearch '<table' CI NEXT
- ENDWHILE
- EzReq "Checked $Ctr tables.\n $ChCtr changed" "ok" var
- Gosub #this ShowIt
-
- xROUTINE ShowIt
- GuiWindow #this RESUME
- SetGad #this 1 HIDE
- SetGad #this 3 HIDE
- SetGad #this 2 SHOW
- Redraw #this
- LVUse #this 2
-
- xROUTINE TransformLine
- TSegmt = ''
- SearchVar LVVar2 '<table' CI first
- PosH = $($$Search.Pos - 1)
-
- WHILE $$Search.Pos > ''
- And $$Search.Pos > $PosH
- ++Ctr
- PosH = $$Search.Pos
- SearchVar LVVar2 '>' CI next
- PosT = $$Search.Pos
- SgLgt = $( $PosT - $PosH + 1 )
- TSegmt = $LVVar2[$PosH][$SgLgt]
- LVMulti ON
- Gosub #this AdaptTableSgmt
- SearchVar LVVar2[$PosT] '<table' CI next
- ENDWHILE
-
- xROUTINE GetImageSgmt
- ImSegmt = ''
- LVSearch '<img ' CI next
- IF $$LV.LINE > ''
- LVMULTI ON
- ;NLine = $$LV.LINE
- PosH = $$Search.Pos
- LVSearch '>' CI next
- PosT = $$Search.Pos
- SgLgt = $( $PosT - $PosH + 1 )
- ImSegmt = $LVVar2[$PosH][$SgLgt]
- ELSE
- NoMore = Yes
- RETURN
- ENDIF
-
- xROUTINE DeleteImageSgmt
- LVline = $LVVar2
- RepVar LVline $ImSegmt "" CI
- LVPut $LVline
- --PosH
- LVPos $$LV.Line $PosH ; does not work EXP
-
- xROUTINE DeleteImageSgmt_
- LVline = $LVVar2
- RepVar LVline $ImSegmt "" CI
- LVPut $LVline
-
- xROUTINE AdaptTableSgmt
- ;Check if need to be adapted
- ; Set DeepTrans Off
- Searchvar TSegmt width= CI first ;width="95%"; width=100%"
- IF $$Search.Pos > ''
- Pos = $$Search.Pos
- Pos0 = $($Pos + 6) ; begin of 'Width number'
- Wdth = $TSegmt[$Pos0][6] ; "94%" "100%" 640 999 (*)
- RepVar Wdth '"' 'µ' CS ; The '"' and '%' characters are diffficult characters
- RepVar Wdth "%" "£" CS ; we replace them here with 'normal' characters
- SearchVar Wdth £ CS First
- IF $$Search.Pos = '' ; % not found, it's a width expressed in absolute value
- IF $Wdth[0][1] = µ ; it's expresses as "540"
- ; EzReq '$Wdth[1] ??' 'ok' var
- SearchVar Wdth[1] µ CS first ; search for the second µ (")
- Pos2 = $$Search.Pos
- Wdth = $Wdth[1][$Pos2] ; => length - 1
- LgtW = $($Pos2 + 1)
- PutIn = '"$NwWdth"' ; Default value = 450
- ELSE ; it's expressed as 540
- Wdth = $Wdth[0][3] ; (*) we don't expect tables from more than 3 digits
- ; it might be =80 (80 ); this does not matter
- LgtW = 3
- PutIn = $NwWdth
- ENDIF
- IF $Wdth > $NwWdth
- NwLVVar2 = $LVVar2
- St = $($PosH + $Pos0 )
- NwLVVar2[$St][$LgtW] = $PutIn ; we replace in situ the width with new width
- LVPut $NwLVVar2
- ++ChCtr
- ENDIF
- ELSE
- ;EzReq "Not transformed" "ok" var
- ENDIF
- ELSE
- ;EzReq "Not transformed" "ok" var
- ENDIf
-
- ;EzReq "**$Wdth\** \n$LVVar2" "ok|stop" var ; = '%' % = Hex 25
-
- ; Set DeepTrans ON
-
- xBUTTON 420 0 60 14 HELP ; <<HELP>>
- GadHelp "..and help will be provided"
- IFEXISTS GUI ~Table.hlp
- GuiLoad guitb:Table.hlp
- ENDIF
- Str1 = "Need more help ?\n"
- Str2 = "Contact me at jduchatelet@arcadis.be"
- EzReq "$.Tb_Goal" "ok|more" var
- IF $var = 0
- EzReq "$.Tb_Start&Usage" "ok|more" var
- IF $var = 0
- EzReq "$.Tb_Start&Usage2" "ok|more" var
- IF $var = 0
- EzReq "$.Tb_IB_Start" "ok|more" var
- IF $var = 0
- EzReq "$.Tb_Extensions" "ok|more" var
- IF $var = 0
- EzReq "$.Tb_Lic&Credits" "ok|more" var
- IF $var = 0
- EzReq "$Str1\#$Str2" "ok|more" var
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- IF $.TbCfg_Help = OFF
- GuiQuit Table.hlp
- ENDIF
-
- xBUTTON 480 0 30 14 Off ; <<Off>>
- GadHelp 'Help information not permanently in ram:'
- LVUse #this 3
- SetGad #this 1 HIDE
- SetGad #this 2 HIDE
- SetGad #this 3 SHOW
- Redraw #this
- LVChange guitb:Table.Cfg
- LVGo #2
- LVPut OFF
- LVSave guitb:Table.Cfg
- .TbCfg_Help = OFF
-
-
- ;xBUTTON 480 0 60 14 Vw3
- ;Gosub #this Show3
-
- xROUTINE Show3
- SetGad #this 1 HIDE
- SetGad #this 2 HIDE
- SetGad #this 3 SHOW
- Redraw #this
-
-
- xNOTIFY Sys:Internet/IBrowse/ ON
- LVUse #this 2
- LVClear
- FlNm = APrint.html
- Fl2Tr = Sys:Internet/IBrowse/APrint.html
- INFO FILE $Fl2Tr
- IF $$FILE.DATE = $$SYS.DATE
- ; EzReq "$$FILE.TIME[0][7] = $$SYS.TIME[0][7]" "ok" var
- IF $$FILE.TIME[0][7] = $$SYS.TIME[0][7]
- LVMode MULTI
- LVChange $Fl2Tr
- CLI 'Faststrip $Fl2Tr 13 10'
- Gosub #this TransformIt
- LVSave ram:APrint.html
- IFEXISTS PORT 'IBROWSE'
- SendRexx IBROWSE 'GOTOURL "file://localhost/ram:APrint.html"'
- ENDIF
- ENDIF
- ENDIF
-
- xROUTINE Storage
- ; EzReq "$$FILE.TIME[0][7] = $$SYS.TIME[0][7]" "ok" var
-
- xLISTVIEW 0 14 600 200 '' LVVar1 '' 30 MULTI
- GadId 1
- GadHelp "Shows imagelist"
-
- xLISTVIEW 0 14 600 200 '' LVVar2 '' 30 MULTI
- GadId 2
- GadHelp "Shows html doc to transform"
-
- xLISTVIEW 0 14 600 200 '' LVVar3 '' 30 MULTI
- GadId 3
- ; "working LV"